package com.yanqu.road.logic.activity.foxcard.game.spell;

import com.yanqu.road.entity.activity.foxcard.FoxConsumeCard;
import com.yanqu.road.logic.activity.foxcard.FoxCardConfig;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;

/**
 * 复制上一张使用的塔罗或星球牌
 */
public class FoxCardSpellUse6 extends FoxCardSpellUseBase {
    @Override
    protected boolean spellUse(FoxCardGameLogic gameLogic) {
        int lastUsedConsumeCardId = gameLogic.getGameData().getLastUsedConsumeCardId();
        if (lastUsedConsumeCardId == 0) {
            return false;
        }

        int cardType = lastUsedConsumeCardId % 100;
        int configId = lastUsedConsumeCardId / 100;

        FoxCardConfig config = gameLogic.getConfig();

        if (consumeCard != null && config.isBuffType8(consumeCard.getVersionEffect()) && gameLogic.getGameData().getConsumeCards().size() >= gameLogic.getGameData().getConsumeCardNumLimit()) {
            //本身有负片效果，且已经达到上限,直接用掉
            return true;
        }
        //看下卡是不是在槽位上、
        boolean isInHole = false;
        for (FoxConsumeCard foxConsumeCard : gameLogic.getGameData().getConsumeCards()) {
            if (foxConsumeCard.equals(consumeCard)) {//不在槽位上才判断数量
                isInHole = true;
            }
        }

        if (!isInHole && gameLogic.getGameData().getConsumeCards().size() >= gameLogic.getGameData().getConsumeCardNumLimit()) {
            return false;
        }

        gameLogic.addNewConsumeCard(cardType, configId, 0);

        return true;
    }
}
